package com.jinghua.treatment.controller;

import com.jinghua.treatment.entity.SysPatient;
import com.jinghua.treatment.service.SysPatientService;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 患者模型控制
 * Created by 王兴光 on 2018/3/16.
 */
@RestController
@RequestMapping("/patient")
public class SysPatientController {
    @Resource
    private SysPatientService patientService;

    /*@ApiOperation(value = "测试")
    @GetMapping("/getPatientAll")
    private List<SysPatient> findAll(){
        return patientService.selectAll();
    }*/

    @ApiOperation(value="患者查询测试，医生编号必须")
    @GetMapping(value="/getPatientByDoctorId",params = {"doctorId"})
    private List<SysPatient> findByDoctorId(Integer doctorId){return patientService.selectByDoctorId(doctorId);}

    @ApiOperation(value = "最新患者查询，最近一周添加的患者")
    @GetMapping(value="/getPatientByWeek",params = {"doctorId"})
    private List<SysPatient> findByWeek(Integer doctorId){return patientService.selectByWeek(doctorId);};

    @ApiOperation(value = "根据患者名称模糊查询患者信息列表，支持拼音")
    @GetMapping(value="/getPatientByName",params = {"doctorId","patientName"})
    private List<SysPatient> findByName(Integer doctorId,String patientName){return patientService.selectByName(doctorId,patientName);};

    @ApiOperation(value="添加患者")
    @GetMapping(value="/addPatient")
    private int addPatient(SysPatient patient){return patientService.insert(patient);}

    @ApiOperation(value="修改患者个人信息")
    @GetMapping(value="/updatePatient")
    private int updatePatient(SysPatient patient){return patientService.updateByPrimaryKey(patient);}

    @ApiOperation(value = "获取患者数量")
    @GetMapping(value = "/getPatientCount",params = {"doctorId"})
    private int findPatientCount(Integer doctorId){return patientService.selectPatientCount(doctorId);}

    @ApiOperation(value = "获取患者信息")
    @GetMapping(value = "/getPatientById",params = {"doctorId"})
    private SysPatient findPatientById(Integer doctorId){return patientService.selectById(doctorId);}
}
